<?php echo form_open('/' . $this->curl . '/permissions/'. $id_role, 'id="myform" name="myform"')?>

<table width="100%" border="0" cellpadding="3" cellspacing="0" id="grid" class="display">
<thead>
<tr>
	<th><?php echo T_('Access'); ?></th>
	<?php $num_roles = count($roles);  ?>
	<?php foreach ($roles as $role): ?>
		<th><?php echo $role ?></th>
	<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($resources as $resource): ?>
		<tr>
			<td>
				<?php if ($resource->parent > 0) echo '&nbsp;&nbsp;&nbsp;&nbsp;'; ?>
				<strong><?php echo $resource->name ?></strong>
			</td>
			<?php foreach ($roles as $id_role => $role): ?>
				<?php $checked = (!empty($permissions[$resource->id][$id_role])) ? TRUE : FALSE; ?>
				<td class="t-center"><?php echo form_checkbox('rid[]', $resource->id.'_'.$id_role, $checked, 'id="rb'. $id_role.'"')?></td>
			<?php endforeach; ?>		
		</tr>
<?php endforeach; ?>
</tbody>
</table>
<br />
<input name="edit" type="submit" class="btn btn_save" id="submit" value="<?php echo T_('Save')?>" />
	
<?php echo form_close()?>

<script type="text/javascript">
var oTable;

$(document).ready(function() {										
	/* Init DataTables */
	oTable = $('#grid').dataTable(
	{
		"aaSorting": [],
		"aoColumns": [
  			{ "bSortable": false }
  			<?php foreach ($roles as $role): ?>
  			,{ "bSortable": false }
  			<?php endforeach; ?>
		],		
														
		"bPaginate": false,
		"bLengthChange": true,
		"bFilter": true,	
		"bSort": true,
		"bInfo": true,
		"bAutoWidth": true,
		"bJQueryUI": true,
		"sPaginationType": "full_numbers"	
	});
});	
</script>